  var core_util={};

  //判断是否全部为空格
  function isSpace(str) {
      var len = str.length;

      for(var i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if (temp != " ") {
		return false;
          }
      }
      return true;
  }
  //检查是否全部为数字
  function isNum(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if (temp >="0" && temp<="9") {
              continue;
          }
          else {
              return false;
          }
      }
      return true;
  }
  //是否有效购买数量
  function isValidBuyNum(buyNum,numLimit) {
    // 无限制
	if (numLimit == null || $.trim(numLimit).length == 0) {
		return true;
	}
	var limitNums = numLimit.split(",");
	for (var i = 0; i < limitNums.length; i++) {
		if (limitNums[i].indexOf("-") != -1) {
			var nums = limitNums[i].split("-");
			if (buyNum >= parseInt(nums[0]) && buyNum <= parseInt(nums[1])) {
				return true;
			}
		} else {
			if (buyNum == parseInt(limitNums[i])) {
				return true;
			}
		}
	}

	return false;
  }
  
  //检查是不是"数字.数字"的格式
  function isPrice(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      var count = 0;
      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if (temp == "." && count<1) {
              count++;
              continue;
          }
          else if (temp >="0" && temp<="9") {
              continue;
          }
          else {
              return false;
          }
      }
      return true;
  }

	/* -- 计算两个字符(YYYY-MM-DD)的日期相隔天数 -- */
	function Date_Compare(asStartDate,asEndDate){
		var miStart = Date.parse(asStartDate.replace(/\-/g, '/'));
		var miEnd = Date.parse(asEndDate.replace(/\-/g, '/'));
		return (miEnd-miStart)/(1000*24*3600);
	}
	/*-- 判断一个字符串(YYYY-MM-DD)的日期是否正确 -- */
	function Date_istrue(asDate){
		var lsDate = asDate + "";
		var loDate = lsDate.split("-");
		if (loDate.length!=3) return false;
		if (isNaN(loDate[0])||isNaN(loDate[1])||isNaN(loDate[2])) return false;

		if (loDate[0].substring(0,1) == "0" && loDate[0].length>=2) {
			loDate[0] = loDate[0].substring(1,2);
		}
		if (loDate[1].substring(0,1) == "0" && loDate[1].length>=2) {
			loDate[1] = loDate[1].substring(1,2);
		}
		if (loDate[2].substring(0,1) == "0" && loDate[2].length>=2) {
			loDate[2] = loDate[2].substring(1,2);
		}


		var liYear = parseInt(loDate[0]);
		var liMonth = parseInt(loDate[1]);
		var liDay = parseInt(loDate[2]);
		if ((loDate[0].length>4)||(loDate[1].length>2)||(loDate[2].length>2)) return false;

//		if (isNaN(liYear)||isNaN(liMonth)||isNaN(liDay)) return false;
		if ((liYear<1900)||(liYear>3000)) return false;
		if ((liMonth>12)||(liMonth<=0)) return false;
		if ((liDay>31) || (liDay<=0)) return false;

		if (Date_getDay(liYear,liMonth)<liDay) return false;
		return !isNaN(Date.UTC(liYear,liMonth,liDay));
	}

	/*-- 返回某年某月的天数-- */
	function Date_getDay(aiYear,aiMonth){
		var loDay = [0,31,28,31,30,31,30,31,31,30,31,30,31];
		if((aiYear%4==0&&aiYear%100!=0)||(aiYear%400==0)) loDay[2] = 29;
			return loDay[aiMonth];
	}
/*打开一个窗口*/
function openWindow(url, actionName, width, height) {
	var left = parseInt((screen.width-width)/2);
	var top = parseInt((screen.height-height)/2);
	var attribute = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,border=0,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(url, actionName, attribute);
}
/*打开一个模态窗口*/
function openModalWindow(url, actionName, width, height) {
	window.showModalDialog(url, actionName,"dialogWidth:" + width + "px; dialogHeight:" + height + "px; status:no;directories:yes;scrollbars:no;Resizable=false;");
}
/*去掉多余的空格*/
function trimString(str) {
	return str.replace(/(^\s*)|(\s*$)/g, "");
}
 

//dateStr 格式为yyyy-MM-dd
function parseDate(dateStr) {
	var s = dateStr.split('-');
	return new Date(s[0], s[1]-1, s[2]);
}
 

//检查数字
function checkNumberPlus(str) {
   var temp = str.split(".");
   if(temp != null && temp.length > 2)
   	return false;
    var i;
    var len = str.length;
    var chkStr = "-1234567890.";
    if (len == 1) {
	if (chkStr.indexOf(str.charAt(i)) < 0) {
	    return false;
	}
    } else {
	if ((chkStr.indexOf(str.charAt(0)) < 0) || ((str.charAt(0) == "0")&&(str.charAt(1)!="."))) {
	    return false;
	}
	 for (i = 1; i < len; i++) {
		if (chkStr.indexOf(str.charAt(i)) < 0) {
			    return false;
		}
	}
    }
    return true;
}
 
/**
 * aFlag true小数部分,false整数部分
 * pos 小数部分为保留的小数位数, 整数部分为整数的round起始位置
 */
function roundPlus(aFlag, pos, value) {
	if(value == "")
		return "0.00";
	if(aFlag) {
      return parseFloat(value).toFixed(pos);
	}
	else {
		var realValue = value.substring(0, value.indexOf("."));//先取整数部分
   	if(realValue == "")//无小数点
			realValue = value;
		if(realValue.length <= pos)
			return value;
		if(pos <= 0)
   		return realValue;
   	else {
      	var roundValue = realValue.substr(realValue.length - pos, 1);//需要判断是否round的数值
      	var beforeRoundValue = realValue.substr(0, realValue.length - pos);
      	var partA = "" + (parseInt(beforeRoundValue) + parseInt((roundValue>=5?1:0)));
   		var toZero = realValue.substring(realValue.length - pos, realValue.length);
      	var partB = "";
			for(var i=0,j=toZero.length; i<j; i++) {
				partB += "0";
			}
      	return partA + partB;
   	}
	}
}
//格式化浮点运算后的数据，保留指位的小数  
function formatData(formName,scale){
   for(var i = 0; i < eval(formName).elements.length; i ++){
      if(eval(formName).elements[i].type == "text")
      	if(eval(formName).elements[i].value.indexOf(".") != -1){
            if(eval(formName).elements[i].value.split(".")[1].length > scale){
               eval(formName).elements[i].value = parseFloat(eval(formName).elements[i].value).toFixed(scale);
            }
      	}
   }
}

   function goUrl(url) {
        document.location.href= url;
    }
  //保留指定位数的小数 num 目标值, precision精确度
  function abandonNum(num,precision){
      return roundPlus(true, precision, num);
  }

// 截取域名
function cutDomain(domain){
	var domains = ['.com.cn','.net.cn','.org.cn','.gov.cn','.com','.cn','.mobi','.net','.org','.hk','.tv','.biz','.cc','.name','.info','.公司','.网络','.中国'];
	var result = "";
	if(IsURL(domain)){
		for(var i=0 ; i<domains.length ; i++){
			if(domain.indexOf(domains[i]) != -1){
				var j = domain.indexOf(domains[i]);
				var temp = domain.substring(0,j);
				if(temp.indexOf('.') != -1){
					result = temp.substring(temp.lastIndexOf('.') + 1);
					break;
				}else{
					if(temp.indexOf('://') != -1){
						result = temp.substring(temp.lastIndexOf('://') + 1);
						break;
					}else{
						result = temp;
						break;
					}
				}
			}
		}
	}
	return result;
}
 
/**
* @param jquery object
* <input type="text" class="w250" value="" tabindex="6" id="email" name="email" />
  <div id="email_hint">
  </div>
  引用 emailHint.css
***/
function emailHint(obj){
	$(document).click(function() {
		$("#email_hint").hide()
	});
	obj.bind('keyup',function(){
		var mail_fix = ["qq.com", "163.com", "126.com", "sina.com", "vip.qq.com", "yahoo.com.cn", "yahoo.cn", "21cn.com", "tom.com"];
		var list_html = '<h1 style="color:#666">请选择邮箱后缀</h1>';
		var id = '#'+$(this).attr('id');
		for (var i = 0; i < mail_fix.length; i++) {
			if ($(this).val().indexOf("@") < 0) {
				list_html += ' <a href="javascript:;"  onclick="javascript:$(\''+id+'\').val(\'' + $(this).val() + '@' + mail_fix[i] + '\');$(\'#email_hint\').hide(); $(\''+id+'\').blur();">' + $(this).val() + '@' + mail_fix[i] + '</a>';
			}else {
				var mail_a = $(this).val().split("@");
				if (mail_fix[i].indexOf(mail_a[1]) == 0){
					list_html += ' <a href="javascript:;"   onclick="javascript:$(\''+id+'\').val(\'' + mail_a[0] + "@" + mail_fix[i] + '\');$(\'#email_hint\').hide();$(\''+id+'\').blur();">' + mail_a[0] + '@' + mail_fix[i] + '</a>';
				}
			}
		}
		$("#email_hint").html(list_html);
		$("#email_hint").css({left:obj.offset().left,top:(obj.offset().top)}).show();
	});
};